<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">

	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
	<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../../JS/common.js"></script>
	<script type="text/javascript" src='../../../JS/SHA-1.js'></script>
	<script type="text/javascript" src="../../../JS/MarketShareFunction/FoodCycleShare.js"></script>
	<script>
		var currid = getID();
		var content = "";
		var DialogWidth = 400;
		var DialogHeight = 310;
		var AddDialog;
		var toolType = TOOLBAR_EDITOR+TOOLBAR_ADD + TOOLBAR_REDO;
		content = AddToolBar(toolType);
		$("#toolbar").append(content);

        function newdata() {
			var pLocation = "UI/Market/FoodSecurityCycle/FoodSecurityCycleAdd.html?id="+AddFlag;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "食品检查周期修改", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}
		/*编辑信息*/
		function editdata() {
			var pLocation = "";
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('Info', "请选择你需要修改数据");
				return;
			}
			if(row.ID == undefined){
					row.ID = AddFlag;
			}
			pLocation = "UI/Market/FoodSecurityCycle/FoodSecurityCycleAdd.html?id=" + row.ID;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "食品检查周期修改", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function redodata() {
			var _url = RemoteLinkAddress + '/market/examinationcycle/list.do';
			$.ajax({
				dataType: "json",
				type: "get",
				url: _url,
				success: function(result) {
					if(result != null) {
						var _data = result;
						$('#dg').datagrid('loadData', _data);
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}

		function dialogClose() {
			AddDialog.dialog('close');
		}

		$('#dg').datagrid({
			url: RemoteLinkAddress + "/market/examinationcycle/list.do",
			toolbar: '#toolbar',
			method: 'get',
			pagination: 'true',
			rownumbers: 'true',
			fitColumns: 'false',
			singleSelect: 'true',
			height: 350,
			/*表格中的列名以及各自列名的ID*/
			columns: [
				[{
						field: 'ID',
						title: 'ID',
						width: '5%',
						align: 'center'
					},

					{
						field: 'CYCLENAME',
						title: '名称',
						width: '20%',
						align: 'center'
					},
					{
						field: 'EXAMINATION_TYPE',
						title: '周期类型',
						width: '20%',
						align: 'center'
					},
					{
						field: 'EXAMINATION_TIME',
						title: '检查时间',
						width: '10%',
						align: 'center'
					},
					{
						field: 'REMIND_TIME',
						title: '提醒时间',
						width: '10%',
						align: 'center',
						formatter: function(value, row, index) {
							return value+"天";
						}
					}, 
					{
						field: 'ISACTIVE',
						title: '是否启用',
						width: '8%',
						align: 'center',
						formatter: function(value, row, index) {
							if(value == 1) {
								return "启用";
							} else {
								return "不启用";
							}
						}
					},
					

				]

			],
			onDblClickRow: function(index, row) {
				if(row.ID == undefined){
					row.ID = AddFlag;
				}
				var pLocation = "UI/Market/FoodSecurityCycle/FoodSecurityCycleAdd.html?ID=" + row.ID;
				$("#ifrmEdit").attr("src", pLocation);
				constructDialog($("#dlg"), "食品检查周期修改", DialogWidth, DialogHeight);
				AddDialog.dialog('open');
			}
		});
//		$('#dg').datagrid('hideColumn', 'ID');
	</script>

</html>